<div class="preview">
<h2><?=$date?></h2>
</div>
<div class="form_section preview">
<input type="hidden" id="mealtime_id" value="<?=$mealtime_id ?>"/>
<table>
    <tr>
        <td class="subtitle">Search Term:</td>
        <td><input type="text" id="search_term" placeholder="Enter a meals name"/></td>
    </tr>
    <tr>
        <td class="subtitle">Category:</td>
        <td>
            <select id="search_cat">
                <option value='-1'>All Categories</option>
                <?foreach($categories->result() as $cat):?>
                <option value="<?=$cat->category_id?>"><?=$cat->category_title?></option>
                <?endforeach;?>
            </select>
        </td>
    </tr><tr>
        <td>
        <td>
            <input type="button" id="reset_filters" class="buttonLight" value="Reset Filters"/>
        </td>
    </tr>
</table>
</div>
<div class="rounded_corners">
<table id="top_table">
    <tr class="preview">
        <td class="subtitle">Search Results:</td>
        <td class="subtitle">Current Meals:</td>
    </tr>
    <tr>
        <td>
           <div class="listContainer">
            <ul class="list" id="search_results">
            </ul>
            </div>
            <input type="button" class="buttonLight" id="add_meal" value="Add Meal ->"/>
        </td>
        <td>
           <div id="meal_list" class="listbox vertical">
                <?if (isset($current)):?>
                <?foreach($current->result() as $result):?>
                <span class="listboxItem" value="<?=$result->meal_id?>">
                    <label class="listboxItemLabel"><?=$result->meal_title?></label>
                    <a href="#" onclick="listboxRemoveItem(this)" class="listboxItemClose"></a>
                </span>
                <?endforeach;?>
                <?endif;?>
            </div> 
        </td>
    </tr>
    <tr>
        <td></td>
        <td>
            <div id="bottom_table_div" class="preview">
                <table id="bottom_table">
                    <tr>
                        <td class="subtitle">Meal Vote Cutoff Time:</td>
                        <td colspan="2">
                            <select id="serving_time">
                                <?foreach($times as $id =>$time):?>
                                <option value="<?=$id?>"<?if ($time == $defaults->default_servetime):?>
                                        selected="selected"
                                        <?endif;?>><?=date('g:i A',strtotime($time))?></option>
                                <?endforeach;?>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td class="subtitle">Orders Allowed:</td>
                        <td>
                            <input type="checkbox" id="orders_allowed"
                                <?if($order_default == 1):?>
                                   checked='checked'
                                <?endif;?>
                                   />
                        </td>
                    </tr>
                    <tr>
                        <td class="subtitle">Meal Order Cutoff Time:</td>
                        <td>
                            <select id="cutoff_time">
                                <?foreach($times as $id => $time):?>
                                <option value="<?=$id?>"<?if ($time == $defaults->default_cutoff):?>
                                        selected="selected"
                                        <?endif;?>><?=date('g:i A',strtotime($time))?></option>
                                <?endforeach;?>
                            </select>
                        </td>
                    </tr>
                </table>
            </div>
        </td>
        <tr>
            <td></td>
            <td><input type="button" class="button" id="save_changes" value="Save Changes"/>
                <input type="button" class="button" id="discard_changes" value="Discard Changes"/>
            </td>
        </tr>
    </tr>
</table>
</div>